add static page to user model#93
add static page to user model#93CLJoker wants to merge 1 commit intohellovietnam93:dao_bao_quang_20143564from
Conversation
Gemfile
Outdated
| # Use sqlite3 as the database for Active Record | ||
| gem 'bcrypt', '3.1.7' | ||
| # | ||
| gem 'bootstrap-sass','3.3.7' |
There was a problem hiding this comment.
sử dụng nháy kép thay cho nháy đơn
Gemfile
Outdated
| @@ -11,6 +11,8 @@ gem 'rails', '~> 5.0.2' | |||
| # Use sqlite3 as the database for Active Record | |||
| gem 'bcrypt', '3.1.7' | |||
| # | |||
There was a problem hiding this comment.
xóa tất cả comment trong file này
| @@ -0,0 +1,3 @@ | |||
| # Place all the behaviors and hooks related to the matching controller here. | |||
There was a problem hiding this comment.
file này k dùng thì xóa đi nhé
app/assets/javascripts/users.coffee
Outdated
| @@ -0,0 +1,3 @@ | |||
| # Place all the behaviors and hooks related to the matching controller here. | |||
There was a problem hiding this comment.
file này k dùng thì xóa đi
app/assets/stylesheets/custom.scss
Outdated
|
|
||
| @mixin box_sizing | ||
| { | ||
| -moz-box-sizing: border-box; |
There was a problem hiding this comment.
1 dấu csh sau dấu : thôi nhé
app/views/static_pages/help.html.erb
Outdated
| @@ -0,0 +1,11 @@ | |||
| <%provide :title, "Help"%> | |||
There was a problem hiding this comment.
cách ra trước và sau %
app/views/users/new.html.erb
Outdated
| @@ -0,0 +1,31 @@ | |||
| <% provide(:title, 'Sign up') %> | |||
There was a problem hiding this comment.
xóa () + sử dụng nháy kép
app/views/users/new.html.erb
Outdated
|
|
||
| <div class="row"> | ||
| <div class="col-md-6 col-md-offset-3"> | ||
| <%= form_for(@user) do |f| %> |
app/views/users/show.html.erb
Outdated
| @@ -0,0 +1,11 @@ | |||
| <% provide(:title, @user.name) %> | |||
config/routes.rb
Outdated
| @@ -1,3 +1,15 @@ | |||
| Rails.application.routes.draw do | |||
| get 'static_pages/signup', to: 'users#new' | |||
There was a problem hiding this comment.
xóa () 1 dấu cách để ngăn thôi nhé
app/controllers/users_controller.rb
Outdated
|
|
||
| def user_params | ||
| params.require :user.permit :name, :email, :phonenumber, :birthday, | ||
| :password, :password_confirmation |
There was a problem hiding this comment.
ident, lùi so với dòng bên trên thôi
app/controllers/users_controller.rb
Outdated
| private | ||
|
|
||
| def user_params | ||
| params.require :user.permit :name, :email, :phonenumber, :birthday, |
There was a problem hiding this comment.
params.require(:user).permit :name ....
em k test code à?
| <%= yield %> | ||
| <%= render "layouts/header" %> | ||
| <div class = container> | ||
| <% flash.each do |message_type, message| %> |
| <% end %> | ||
| <%= yield %> | ||
| <%= render "layouts/footer" %> | ||
| <%= debug(params) if Rails.env.development? %> |
| <div class="alert alert-danger"> | ||
| The form contains <%= pluralize(@user.errors.count, "error") %>. | ||
| </div> | ||
| <ul> |
| <em>Ruby on Rails Tutorial</em>book</a>. | ||
| </p> | ||
|
|
||
| </body> |
app/views/static_pages/help.html.erb
Outdated
| <em>Ruby on Rails Tutorial</em>book</a>. | ||
| </p> | ||
|
|
||
| </body> |
app/views/static_pages/home.html.erb
Outdated
| This is the home page for the <a href="http://www.railstutorial.org/"> | ||
| Ruby on Rails Tutorial</a> sample application. | ||
| </h2> | ||
| <%= link_to "Sign up now!", '#', class: "btn btn-lg btn-primary"%> |
| # Use Capistrano for deployment | ||
| # gem 'capistrano-rails', group: :development | ||
| gem "bcrypt", "3.1.7" | ||
|
|
There was a problem hiding this comment.
e xóa dòng này và các dòng 13, 15, 17, 19, 21, 23, 25, 27 nhé
app/helpers/users_helper.rb
Outdated
| @@ -0,0 +1,7 @@ | |||
| module UsersHelper | |||
| def gravatar_for user, size: 80 | |||
| gravatar_id = Digest::MD5::hexdigest(user.email.downcase) | |||
app/helpers/users_helper.rb
Outdated
| def gravatar_for user, size: 80 | ||
| gravatar_id = Digest::MD5::hexdigest(user.email.downcase) | ||
| gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}" | ||
| image_tag(gravatar_url, alt: user.name, class: "gravatar") |
app/views/layouts/_header.html.erb
Outdated
| @@ -0,0 +1,12 @@ | |||
| <header class="navbar navbar-fixed-top navbar-inverse"> | |||
| <div class="container"> | |||
| <%= link_to "Sample App","#", id:"logo" %> | |||
There was a problem hiding this comment.
thiếu khoảng trắng
viết đúng convention thì như này em nhé:
<%= link_to "Sample App", "#", id: "logo" %>
app/views/layouts/_shim.html.erb
Outdated
| @@ -0,0 +1,4 @@ | |||
| <!--[if lt IE 9]> | |||
| <script src = "//cdnjs.cloudflare.com/ajax/libs/html5shiv/r29/html5.min.js"> | |||
config/routes.rb
Outdated
| @@ -1,3 +1,15 @@ | |||
| Rails.application.routes.draw do | |||
| get "static_pages/signup", to: "users#new" | |||
|
|
|||
There was a problem hiding this comment.
e xóa dòng này và các dòng 5, 7, 9, 11 nhé
config/routes.rb
Outdated
|
|
||
| resources :users | ||
|
|
||
| # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html |
| # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) | ||
| # Character.create(name: 'Luke', movie: movies.first) | ||
| 10.times do |n| | ||
| User.create name: "User #{n}", email: "email-#{n}@gmail.com" |
There was a problem hiding this comment.
e xóa hết comment trong file này và sửa lại cách viết dòng này nhé:
User.create! name: "User #{n}", email: "email-#{n}@gmail.com"
| @@ -0,0 +1,14 @@ | |||
| require 'test_helper' | |||
| @@ -0,0 +1,9 @@ | |||
| require 'test_helper' | |||
app/views/static_pages/help.html.erb
Outdated
| <h1>Help</h1> | ||
| <p> | ||
| Get help on the Ruby on Rails Tutorial at the | ||
| <a href="http://www.railstutorial.org/help">Rails Tutorial help section</a>. |
There was a problem hiding this comment.
ident, sao lại lùi vòa thé?
app/controllers/users_controller.rb
Outdated
| private | ||
|
|
||
| def user_params | ||
| params.require (:user).permit :name, :email, :phonenumber, :birthday, |
sign up sign up + deleted folder static page readd fix fix second time fix time 3 fix time 4 fix time 5 fix 6 time
| end | ||
|
|
||
| gem "rails", "~> 5.0.2" | ||
|
|
| # See https://github.com/rails/execjs#readme for more supported runtimes | ||
| # gem 'therubyracer', platforms: :ruby | ||
| gem "bcrypt", "3.1.7" | ||
|
|
| <nav> | ||
| <ul> | ||
| <li><%= link_to "About", static_pages_about_path %></li> | ||
| <li><%= link_to "Contact", '#' %></li> |
| @@ -0,0 +1,11 @@ | |||
| <%provide :title, "Home"%> | |||
| This is the home page for the <a href="http://www.railstutorial.org/"> | ||
| Ruby on Rails Tutorial</a> sample application. | ||
| </h2> | ||
| <%= link_to "Sign up now!", "#", class: "btn btn-lg btn-primary"%> |
| # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) | ||
| # Character.create(name: 'Luke', movie: movies.first) | ||
| 10.times do |n| | ||
| User.create name: "User #{n}", email: "email-#{n}@gmail.com" |
There was a problem hiding this comment.
e thêm dấu chấm than ! ngay sau create nhé:
User.create! name: "User #{n}", email: "email-#{n}@gmail.com"
sign up
sign up + deleted folder static page